<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.kaishengit.entity.User" %>
<!DOCTYPE HTML>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" href="css/bootstrap.min.css" />
	<script type="text/javascript"src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	
	<style type="text/css">
		a:hover{
			text-decoration:none;
		}
	</style>
</head>
<body onload="checkdelete()">
	<div class="navbar">
		<div class="navbar-inner">
			<div class="container">
				 
				<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</a>
				 
				<!-- Be sure to leave the brand out there if you want it shown -->
				<a class="brand" href="#">欢迎使用PM系统</a>
				<ul class="nav" >
					<li class="active"  style="margin-left:40px;">
						<a href="personmanager.jspx">成员管理</a>
					</li>
					<li><a href="newproject.jspx" style="margin-left:40px;">新建项目</a></li>
					<li><a href="projectlistview.jspx" style="margin-left:40px;">项目列表</a></li>
					<li><a href="#" style="margin-left:40px;">我的任务</a></li>
					<li><a href="#" style="margin-left:40px;">附加功能</a></li>
				</ul>
				 
				<!-- Everything you want hidden at 940px or less, place within here -->
				<ul class="nav pull-right">
					<li>
						<a href="#">欢迎您：</a>
					</li>
					<li class="divider-vertical"></li>
					<li style="margin-top:10px;"><%=((User)session.getAttribute("session_user")).getUsername() %></li>
				</ul>
			</div>
		</div>
    </div>
	

	

	
	
	<ul id="tab" class="nav nav-tabs" style="margin-left:200px;width:800px;">
		<li class="active">
			<a data-toggle="tab" href="#home">添加新用户</a>
		</li>
		<li id="mydelete" class="">
			<a data-toggle="tab" href="#profile">删除用户</a>
		</li>
	</ul>
	<div id="myTabContent" class="tab-content">
		<div id="home" class="tab-pane fade active in">
			<form id="myform1" class="well" action="addperson.jspx" method="post" style="margin-left:200px;width:800px;">
			<%
				String state = (String)request.getAttribute("state");
				String msg = "";
				if("10002".equals(state)) {
					msg="添加成功";
			%>
				  <div id="msgerror" class="alert alert-error">
	    				<%=msg%>
	   			 </div>
			
			<%} else if("10001".equals(state)) {
				msg="用户名已经存在";
			%>
			
				<div id="msgerror" class="alert alert-error">
	    				<%=msg%>
	   			 </div>
	   		<%} %>	 
				<label>用户名</label>
				<input id="username1" type="text" class="span3" name="username">
				<label>密码</label>
				<input id="password" type="text" class="span3" name="password">
				<br/>
				
				<div id="msgcheck1" class="alert alert-error"> 
	  		    </div>
				<td>
					<button type="submit" class="btn btn-success">保存</button>
				</td>
				<td>
					<button class="btn btn-danger"  href="#">取消</button>
				</td>
			</form>
		</div>
		<div id="profile" class="tab-pane fade">
			<form id="myform2" class="well" action="deleteperson.jspx" method="post" style="margin-left:200px;width:800px;">
			              
				<%
					String state1 = (String)request.getAttribute("state1");
					String msg1 = "";
					if("10002".equals(state1)) {
						msg="删除成功";
				%>
					  <div id="msgerror1" class="alert alert-error">
		    				<%=msg%>
		   			 </div>
				
				<%}else if("10001".equals(state1)) {
					msg="用户名不存在";
				%>		
				    <div id="msgerror1" class="alert alert-error">
		    				<%=msg%>
		   			</div>
		   		<%} %>	
			
			
			
				<label>要删除的用户名</label>
				<input id="username2" type="text" class="span3" name="username">
				<br/>
				
				<div id="msgcheck2" class="alert alert-error"> 
	  		    </div>
				<td>
					<button type="submit"class="btn btn-success" href="#">保存</button>
				</td>
				<td>
					<button type="submit" class="btn btn-danger"  href="#">取消</button>
				</td>
			</form>
		</div>
	</div>
	
	<script type="text/javascript">
		var msgerror1 = document.getElementById("msgerror1");
		var mydelete = document.getElementById("mydelete");
		var profile = document.getElementById("profile");
		function checkdelete() {
			if(msgerror1!=null && msgerror1.innerHTML=="删除成功") {
				mydelete.className="active";
				profile.className="tab-pane fade active in";
			}
		}
		
		
		
		var msgcheck1 = document.getElementById("msgcheck1");
		var msgcheck2 = document.getElementById("msgcheck2");
		
		var username1 = document.getElementById("username1");
		var username2 = document.getElementById("username2");
		var password = document.getElementById("password");
		var msgerror = document.getElementById("msgerror");
		var msgerror1 = document.getElementById("msgerror1");
		
		msgcheck1.style.display="none";
		msgcheck2.style.display="none";
		
			document.getElementById("myform1").onsubmit=function() {
				if(username1.value=="" || password.value=="") {
					msgcheck1.style.display="block";
					msgcheck1.innerHTML="不能为空";
					return false;
				}
			}
			
			
			document.getElementById("myform2").onsubmit=function() {
				if(username2.value=="") {
					msgcheck2.style.display="block";
					msgcheck2.innerHTML="不能为空";
					return false;
				}
			}
			
			
			username1.onfocus = function() {
				msgcheck1.style.display="none";
				if(msgerror!=null && msgerror.innerHTML!="")
					msgerror.style.display="none";
			
			}
			
			
			password.onfocus = function() {
				msgcheck1.style.display="none";
				if(msgerror!=null && msgerror.innerHTML!="")
				msgerror1.style.display="none";
				
			}
			
			
			username2.onfocus = function() {
				msgcheck2.style.display="none";
				if(msgerror1!=null && msgerror1.innerHTML!="")
					msgerror1.style.display="none";
			
			}
			
			
			
			
			
	</script>
	
</body>
</html>